//
//  XCSingerButtonCollectionViewCell.m
//  SoundOfNature
//
//  Created by 梁新昌 on 16/3/11.
//  Copyright © 2016年 梁新昌. All rights reserved.
//

#import "XCSingerButtonCollectionViewCell.h"
#import "UIImageView+WebCache.h"
@implementation XCSingerButtonCollectionViewCell

- (void)dealloc {
    [_picImageView release];
    [_titleLable release];
    [_singerDataModel release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.picImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.titleLable = [[XCBaseLable alloc] initWithFrame:CGRectZero];
        
        [self.contentView addSubview:self.picImageView];
        [self.contentView addSubview:self.titleLable];
        
        [self.picImageView release];
        [self.titleLable release];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.picImageView.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height - 20);
    [self.picImageView.layer setCornerRadius:5];
    self.picImageView.layer.masksToBounds = YES;
    //    然后再给图层添加一个有色的边框
    self.picImageView.layer.borderWidth = 1;
    self.picImageView.layer.borderColor = [[UIColor colorWithWhite:0.902 alpha:0.8] CGColor];
    self.titleLable.frame = CGRectMake(0, self.picImageView.bounds.size.height, self.bounds.size.width, 20);
    self.titleLable.font = [UIFont systemFontOfSize:13];
    
}
- (void)setSingerDataModel:(XCSingerDataModel *)singerDataModel {
    if (_singerDataModel != singerDataModel) {
        [_singerDataModel release];
        _singerDataModel = [singerDataModel retain];
    }
    
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:singerDataModel.pic_url]placeholderImage:[UIImage imageNamed:@"Image-p"]];
    
    self.titleLable.text = singerDataModel.title;
    
}
@end
